package com.j.sdks.bll;

/**
 * 
 * @author jm pageBean 对象
 */
public class PageBean {

	private int pageNo;// 当前页码
	private int pageCount; // 总页数
	private int rowCount;// 总行数
	private int pageSize;// 每页显示多少条
	private int startRow;// 从第几行开始

	// private String orderBy;// 降序还是升序
	// private String orderDir;//被排序的字段
	// public static final int ORDER_DESC = 1;
	// public static final int ORDER_ASC = 1;

	public PageBean() {
		this.pageSize = 10;
		this.pageNo = 1;
		this.startRow = 0;
		this.rowCount = 0;
	}

	// public PageBean(int pageNo, int pageSize, String orderBy, String
	// orderDir) {
	// this.pageSize = pageSize;
	// this.pageNo = pageNo;
	// this.orderBy = orderBy;
	// this.orderDir = orderDir;
	// }

	public int getPageNo() {
		if (this.pageNo <= 0) {
			this.pageNo = 1;
		}
		return this.pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
		this.startRow = ((pageNo - 1) * this.pageSize);
	}

	public int getPageCount() {
		return this.pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getRowCount() {
		return this.rowCount;
	}

	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
		if (this.pageSize <= 0) {
			this.pageSize = 10;
		}
		this.pageCount = ((rowCount + this.pageSize - 1) / this.pageSize);
	}

	public int getPageSize() {
		return this.pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
		this.startRow = ((this.pageNo - 1) * pageSize);
	}

	public int getStartRow() {
		if (this.startRow < 0) {
			this.startRow = 0;
		}
		return this.startRow;
	}

	public void setStartRow(int startRow) {
		this.startRow = startRow;
	}

	@Override
	public String toString() {
		return "PageBean [pageNo=" + pageNo + ", pageCount=" + pageCount
				+ ", rowCount=" + rowCount + ", pageSize=" + pageSize
				+ ", startRow=" + startRow + "]";
	}

	// public String getOrderBy() {
	// return this.orderBy;
	// }
	//
	// public void setOrderBy(String orderBy) {
	// this.orderBy = orderBy;
	// }

	// public String getOrderDir() {
	// return this.orderDir;
	// }
	//
	// public void setOrderDir(String orderDir) {
	// this.orderDir = orderDir;
	// }
	
}
